package com.whfc.fmam.redis.impl;

import com.whfc.fmam.redis.FmamUnitRedisDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/10/10 14:08
 */
@Component
public class FmamUnitRedisDaoImpl implements FmamUnitRedisDao {

    private String key = "fmam_unit";

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Override
    public void put(Integer unitId, String unitName) {
        redisTemplate.opsForHash().put(key, String.valueOf(unitId), unitName);
    }

    @Override
    public String get(Integer unitId) {
        return (String) redisTemplate.opsForHash().get(key, String.valueOf(unitId));
    }
}
